package se.hexabit.imagebank;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class Config {

	private static Config instance = null;

	Properties defaultProps = null;

	protected Config() {
		// Protected prevents instantiation
		defaultProps = new Properties();
		defaultProps.put("ib.root.path", System.getProperty("user.home"));
		defaultProps.put("ib.file.types", "jpg,jpeg,tif,tiff");
		defaultProps.put("ib.dest.path", System.getProperty("user.home") + "/output");
	}

	public static Config getInstance() {
		if (instance == null) {
			instance = new Config();
		}
		return instance;
	}

	public Properties readConfig(File file) {
		FileInputStream in;
		try {
			if (file != null) {
				in = new FileInputStream(file);
				defaultProps.load(in);
				in.close();
			}
		} catch (IOException e) {
			System.err.println(e);
		}
		return defaultProps;
	}
}
